<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        /* div[data] {
            background-color: red;
        } */

        /* div[data="a"] {
            background-color: green;
        } */

        /* div[data~="a"] {   */
            /* 用于class属性比较好 */
            /* background-color: #008c8c;
        }   */


        div[data|="a"] {
            background-color: blue;
        }

    </style>
</head>
<body>
    <div class="demo" data="a">data1</div>
    <div data="a">1</div>
    <div data="b">2</div>
    <div data="a b">3</div>
    <div data="aa b c">4</div>
    <div data="a- a b">5</div>
    <div>data2</div>
</body>
</html>